#include <iostream>
#include <zmq.hpp>
#include <string>
#include <sys/time.h>
#include "ZQ_CPP_LIB/time_cost.hpp"
#include "share.hpp"


int main(){
  zmq::context_t context(1);
  zmq::socket_t socket(context,ZMQ_REP);
  std::string server_host = "tcp://*:"+server_port;
  socket.bind(server_host);
  struct timespec tv = {1,0};
  static int cnt = 0;
  while (true){
    zmq::message_t request;
    socket.recv(&request);
    //std::cout<<"Received: " << (char*)request.data() << std::endl;
    zmq::message_t reply(size);
    //memcpy((void*)reply.data(),"World",5);
    socket.send(reply);
    cnt++;
    if (cnt == 1){
      zq_cpp_lib::get_start_time();

    };
    if (cnt == n){
      zq_cpp_lib::get_end_time();
      double timecost_ms = zq_cpp_lib::get_cost_time_by_ms();
      std::cout<<"time cost(ms) = " << timecost_ms << std::endl;
    };
    if (cnt%(n/100)==0){
      std::cout<<"cnt="<<cnt<<std::endl;
    };
  };
  return 0;
};
